This homework sheet is due on the 3rd of December. You may submit your answers in pairs, in R (,Rmd file). Submission will be performed electronically via Moodle.
We urge you to start solving this sheet as soon as possible and, if you have any questions, come to visit us in reception hours next week.
As we did in the exercise 4, show that if confidence intervals are constructed using a given confidence level from an infinite number of independent sample statistics, the proportion of those intervals that contain the true value of the parameter will be equal to the confidence level.
In the exercise we have seen it for the confidence interval for the mean of i.i.d samples from normal distribution with known variance, here we will do it for the confidence interval of sigma (as you have seen in lecture 3, slide #20).
Modify the code -
miu = 10
sigma = 3
n = 10
alpha = 0.1
N_tests <- 10000
counter <- 0
error = qnorm(1-alpha/2)*(sigma/sqrt(n))
for (i in 1:N_tests)
{sample = rnorm(n,miu,sigma)
sample_mean <- mean(sample)
left <- sample_mean-error
right <- sample_mean + error
between <- (left <= miu) & (miu <= right)
counter <- counter+between}
estimated_confidence <- (counter/N_tests)
true_confidence <- 1- alpha
print (abs(estimated_confidence - true_confidence))
## [1] 4e-04
In this question we will look at the iris classic dataset (built in in r environment):
* Sepal.Length will appear on the x axis
* Sepal.Width will appear on the y axis
* Each point will have color based on the species of that given iris
* The figure will have a legend that explains the colors of the species